<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 5/10/24
 * Time: 6:13 PM
 */

namespace app\adminapi\lists\landing_page;

use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\jump\Jump;
use app\common\model\landing_page\LandingPage;


/**
 * 落地页
 *
 * Class OrderLists
 * @package app\adminapi\lists
 */
class LandingPageLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * 搜索条件
     *
     * @return array
     */
    public function setSearch(): array
    {
        return [];
    }


    public function queryWhere(): array
    {
        return [];
    }


    public function count(): int
    {
        return Jump::count();
    }


    /**
     * 获取列表
     *
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function lists(): array
    {
        $list = LandingPage::field('id, page_no, title, platform, promotion_link_id, admin_id, head_img, content, footer_img, next_button_content, read_button_content, create_time, update_time')
            ->append(['admin_name', 'platform_name'])
            ->order('create_time', 'desc')
            ->limit($this->limitOffset, $this->limitLength)
            ->select()
            ->toArray();

        foreach ($list as &$item) {
            $item['landing_page_url'] = env('landing.landing_page_url') . '?page_no=' . $item['page_no'];
        }

        return $list;
    }
}
